package com.duobab.springbootredisdemo.controller;

import com.duobab.springbootredisdemo.domain.Attr;
import com.duobab.springbootredisdemo.utils.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController()
@RequestMapping("/redis")
public class RedisController {
    @Autowired
    private RedisUtils redisUtils;

    @PostMapping(value = "set")
    public void addKV(@RequestBody Attr attr) {
        redisUtils.setKV(attr.getKey(), attr.getValue());
    }

    @DeleteMapping(value = "/{key}")
    public void addKV(@PathVariable("key") String key) {
        redisUtils.delKey(key);
    }
}
